package cn.santi.controller;

import cn.santi.domain.Punch;
import cn.santi.emuns.R;
import cn.santi.service.PunchService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/punch")
public class PounchContrlloer {
    @Autowired
    private PunchService ps;
    @GetMapping("/addpunch")
    public R addpunch(Punch punch){
        boolean b = ps.save(punch);
        if (b){
            return R.ok(b);
        }
        return R.fail("签到失败");
    }
    @GetMapping("/querypunch")
    public R querypunch(int uid,String year){
        QueryWrapper<Punch> wrapper = new QueryWrapper<>();
        wrapper.eq("uid",uid).eq("year",year);
        return R.ok(ps.list(wrapper));
    }
}
